﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StuManagementSystem
{
    public partial class frm_Myself : Form
    {
        private int StuCode;
        DbContext db = new DbContext();
        public frm_Myself()
        {
            InitializeComponent();
        }
        public frm_Myself(int Code)
        {
            InitializeComponent();
            this.StuCode = Code;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frm_Myself_Load(object sender, EventArgs e)
        {
            string sql = string.Format(@"SELECT * FROM dbo.StuInfo,dbo.StuSex,dbo.StuGrade WHERE StuInfo.StuSexId = StuSex.StuSexId AND StuGrade.StuGradeId = StuInfo.StuGradeId AND StuCode = {0}",StuCode);
            DataSet ds = db.ExecDataSet(sql);
            var dt = ds.Tables[0].Rows[0];

            txt_StuCode.Text = dt["StuCode"].ToString();
            txt_StuPwd.Text = dt["StuPwd"].ToString();
            txt_StuSex.Text = dt["StuSexName"].ToString();
            txt_StuGrade.Text = dt["StuGradeName"].ToString();
            txt_StuTelephone.Text = dt["StuTelephone"].ToString();
            txt_StuAddress.Text = dt["StuAddress"].ToString();
            txt_StuBirthDay.Text = dt["StuBirthDay"].ToString();
            txt_StuEmail.Text = dt["StuEmail"].ToString();
        }
    }
}
